import React, {Component} from 'react'
import '../../static/scss/user/userPageTemplate.scss'
import commonConfig from '../../static/js/commonConfig'
import {Button, Form} from 'antd'

class UserPageTemplate extends Component {
    state = {}

    componentDidMount() {
        if (commonConfig.judgeUserLoginStatus()) {
            this.props.history.push({pathname: '/view'});
        }
    }

    redirectRegister = () => {
        const {isLogin, history} = this.props;
        history.push({
            pathname: !isLogin ? 'login' : 'register'
        });
    }

    render() {
        const {isLogin, children, onFinish, initialValues, weChartLogin} = this.props;
        const layout = {
            labelCol: {
                span: 5
            },
            wrapperCol: {
                span: 19
            }
        }
        return (
            <>
                <div className="user_page_template">
                    <div className="container_panel">
                        <div className="content_section">
                            <div className="logo_section">
                                <h1>{commonConfig.projectName}</h1>
                                {isLogin ? <h5>Field archaeology project management system</h5> : null}

                            </div>
                            <Form ref="userRef" {...layout} size="large" onFinish={onFinish} autoComplete="off"
                                  initialValues={initialValues}
                                  className={isLogin ? 'loginForm' : 'registerForm'}>
                                {children}
                                {!weChartLogin ? <Form.Item noStyle>
                                    <Button className="submit_btn" size="large" htmlType="submit"
                                            type="primary">{isLogin ? '登录' : '注册'}</Button>
                                </Form.Item> : null}
                                {/* <Form.Item noStyle>
                                    {isLogin ?
                                        <>
                                            {weChartLogin ? <p className="fast_login"><span
                                                    onClick={loginSelectHandle}>账号密码登录</span></p> :
                                                <p className="fast_login">
                                                    <span onClick={loginSelectHandle}><Iconfont
                                                        type="icon-icon-wechat-qy"/>第三方登录</span>
                                                </p>}
                                        </> :
                                        <p className="fast_login">已经注册？<span onClick={this.redirectRegister}>立即登录</span>
                                        </p>}
                                </Form.Item> */}
                            </Form>
                        </div>
                        {/* <div className={'tip_picture ' + (isLogin ? 'active' : '')}>
                            <h1>{tipObj.title}</h1>
                            <h4>{tipObj.en}</h4>
                            <p>{tipObj.info}</p>
                            <span className="register_btn"
                                  onClick={this.redirectRegister}>{isLogin ? '立即注册' : '返回登录'}</span>
                        </div> */}
                    </div>
                    <div className="footer_style"/>
                </div>
            </>
        )
    }
}

export default UserPageTemplate;